/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.adastros.buildingmanager.model;

import java.util.Iterator;
import java.util.List;

/**
 *
 * @author developer
 */
public class Building {

  private String fiscalId ;

  private List<BuildingStaff> allStaff ;
  
  private List<BuildingSection> allSections ;
  
  private List<BuildingStaff> currentStaff ;

  private Person findPersonWithRole(BuildingStaff.Role role) {
    Person person = null ;
    Iterator<BuildingStaff> it = currentStaff.iterator() ;

    while (null == person && it.hasNext()) {
      BuildingStaff staff = it.next() ;
      
      if (staff.getRole() == role)
        person = staff.getPerson() ;
    }
    
    return person ;    
  }
  
  
  public Person getPresident() {
    return findPersonWithRole(BuildingStaff.Role.PRESIDENT) ;
  }
  
  public Person getSecretary() {
    return findPersonWithRole(BuildingStaff.Role.SECRETARY) ;
  }
  
  public Person getManager() {
    return findPersonWithRole(BuildingStaff.Role.MANAGER) ;
  }
}
